![]() |
Introducing: Loops & Animation Continue
OPENING QUESTION: Imagine you could draw perfect lines to a perfect length and draw perfect angles connecting other perfect lines. It's gonna drive ya a bit nuts, but for purposes of this exercise we are going to (quite appropriately, but we'll revisit that in a few moments) determine the angles we draw from a different perspective then usual... that is by way of saying we'll determine the angle that we draw by taking 360/n where n is the number of sides in our polygons. You'll just have to take it on trust for now. To wit:
Which steps repeat? OBJECTIVES:
HELP FILES:
WORK O' THE DAY: The first step in using a loop (generally) and doing animation (specifically) is to sketch, list or otherwise write an algorithm that deals with JUST the repetitive parts. Anything that repeats goes in the loop, everything else stays out With that in mind, please re-create the table I wrote on the board yesterday for polygons with equal sides and equal angles. Let's start with just the shapes that work 'evenly' into 360 (yes, it works, don't freak out, we'll determine WHY it works later):
Now let's start by writing an algorithm for drawing a square as if we could perfectly and precisely outline the steps
Something like this perhaps:
Now let's write an algorithm for drawing a pentagon Something like this perhaps: Notice that if we realize that the 'turtle' moves in relation to the EXTERNAL (not interior) angles then if N is the Number of sides of the polygon then:
|